import {createRouter, createWebHistory} from 'vue-router'
import extensions from '@/utils/extensions'
import store from '@/store'

const routes = [
  {path: '/login', hidden: true, component: () => import('@/views/login/index')},
  ...extensions,
  {path: '/404', hidden: true, component: () => import('@/views/404/index')},
  {path: '/:pathMatch(.*)', redirect: '/404', hidden: true}// 设置路由不存在跳转404
]
// 设置路由
store.dispatch('system/setRouters', routes).then(() => {})

const router = createRouter({
  history: createWebHistory(), // hash模式：createWebHashHistory，history模式：createWebHistory
  routes
})

export default router
